package com.zqxq.lottery.service.sys.impl;

import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.zqxq.common.utils.DispatcherUtils;
import com.zqxq.common.utils.StrUtils;
import com.zqxq.lottery.entity.po.sys.SysConfigPO;
import com.zqxq.lottery.entity.vo.sys.SysConfigVO;
import com.zqxq.lottery.mapper.sys.SysConfigMapper;
import com.zqxq.lottery.service.sys.ISysConfigService;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author 苦智
 * @date 2018/6/29 15:26
 * @description
 * @ClassName SysConfigServiceImpl
 */
@Service
public class SysConfigServiceImpl extends ServiceImpl<SysConfigMapper,SysConfigPO> implements ISysConfigService{
    @Override
    public String getValueByKey(String key) {
        SysConfigPO sysConfigPO = baseMapper.getByKey(key);
        if (sysConfigPO == null || StrUtils.isEmpty(sysConfigPO.getCval())){
            return "";
        }
        return sysConfigPO.getCval();
    }

    @Override
    public Page getSysConfigList(Map<String,Object> paramMap) {
        Page page = new Page(DispatcherUtils.parseInt(paramMap.get("pageNo")),DispatcherUtils.parseInt(paramMap.get("pageSize")));
        List<SysConfigVO> list = baseMapper.getSysConfigList(page,paramMap);
        page.setRecords(list);
        return page;
    }
}
